<template>
    <div>
        <div class="course-content-main">
            <div class="course-content-main-outer">
                <div class="course-content-main-inner">
            <template>
                <el-tabs v-model="activeName" @tab-click="handleClick">
                    <el-tab-pane  label="课程描述" name="first" v-html="courseList.courseDetail" class="content-text content-text-box is-active"></el-tab-pane>
                    <el-tab-pane label="目录" name="second" class="content-text-box">
                        <div v-for="(item,index) in courseClassList" :key="index-100">
                            <h3 class="bigTitle">{{item.sectionName}} <div class="down"><img src="images/down.png" alt="">下载</div></h3>

                            <div v-for="(v,i) in item.subSections" :key="i-100" class="smallTitle">
                                {{ v.sectionName}}
                            </div>
                        </div>
                    </el-tab-pane>
                    <el-tab-pane label="评论" name="third">
                        <p>评论</p>
                        <div class="evaluation">
                            <el-rate
                                    v-model="value"
                                    show-text>
                            </el-rate>
                        </div>
                        <div>
                               <textarea name="" id="" placeholder="请尽情评论吧" cols="30" rows="10" class="comments">

                               </textarea>
                        </div>
                        <div class="publish">发表评论</div>
                        <div class="line">

                        </div>
                        <div>
                            <div class="head-portrait" v-for="(item,index) in commentContent" :key="index-100">
                                <div style="overflow: hidden">
                                    <div class="circle-img">
                                        <img :src="item.user.avatarUrl" alt="">
                                    </div>
                                    <div class="head">{{item.user.nickname}}</div>
                                    <div class="star-1">
                                        <el-rate
                                                v-model="item.score"
                                                show-text>
                                        </el-rate>
                                    </div>
                                </div>

                                <div class="text-1">{{item.commentContent}}</div>
                                <div class="reply-box" >
                                    <div class="time">回复</div>
                                    <span class="reply">{{item.createdTime}}</span>
                                </div>
                                <div class="reply-box-2" v-for="(v,i) in item.subCommentList" :key="i-1000">
                                   <div class="replay-box-content">
                                       <div class="portrait"><img :src="v.user.avatarUrl" alt="" class="head-portrait-2"></div>
                                       <span class="portrait-name">{{v.user.nickname}}</span>
                                       <span class="portrait-reply">回复</span>
                                       <span class="portrait-name">{{item.user.nickname}}:</span>
                                       <span class="portrait-content">{{v.commentContent}}</span>
                                       <div class="portrait-time">{{v.createdTime}}</div>
                                   </div>
                                </div>
                            </div>
                        </div>
                        <div class="paging" >
                            <el-pagination
                                    background
                                    layout="prev, pager, next"
                                    :total="totalLixt.total"
                                    @current-change="paging">
                            </el-pagination>
                        </div>
        </el-tab-pane>
                </el-tabs>
            </template>
                </div>
            </div>
        </div>
    </div>
</template>

<script>


    import {getComments, getDetail} from "../../../api/course";

    export default {
        name: "courseContent",
        data() {
            return {
                activeName: 'second',
                courseList:"",//接收课程描述
                courseClassList:"",//接收目录数据
                commentContent:"",//接收评论内容
                totalLixt:""//接收页数总量
            };
        },
        methods: {
            handleClick(tab, event) {
                console.log(tab, event);
            },
            paging(page){
                getComments(this.$route.query.id,10,page).then(res=>{
                    console.log(res)
                    this.totalLixt=res
                    this.commentContent=res.rows
                    // this.valueStar=res.
                })
            }
        },
        created() {
            getDetail(this.$route.query.id).then(res=>{
                this.courseList=res.data;
                // console.log(res.data.sections)
                this.courseClassList = res.data.sections

            }).catch(err=>{
                console.log(err)
            }),
            // getComments(this.$route.query.id,10,1).then(res=>{
            //     console.log(res)
            //     this.totalLixt=res
            //     this.commentContent=res.rows
            // })
                this.paging(1)
        },
    }
</script>

<style scoped>

.course-content-main {
    width: 100%;
    background: #fff;
    margin-top: 20px;
    border-radius: 3px;
}
    .course-content-main-outer {
        padding: 0 10px;
    }
    .content-text {
        color: rgba(0,0,0,.65);
        font-size: 14px;
        font-variant: tabular-nums;
        line-height: 1.5;
    }
    .content-text-box {
        width: 1120px;
        padding:30px;
    }
    .el-tabs__nav-wrap is-top {
        margin-left: 10px;
    }
    /deep/.is-top {
        margin-left: 10px;
    }
    /deep/.el-tabs__active-bar {
        background-color: #00cf8c;
        width: 70px!important;
        /*margin-left: 5px;*/
    }
    /deep/.el-tabs__item {
        /*color: #00cf8c;*/
    }
    /deep/.el-tabs__item.is-active,
    .el-tabs__item.is-active:hover{
        color: #00cf8c;
    }
 /deep/.el-tabs__active-bar {
     margin-left: 5px;
 }
/deep/.el-tabs__item:hover{
    color: rgb(0, 207, 140);
}
    .smallTitle{
        position: relative;
        margin: 10px 0 20px;
        width: 1170px;
        /*height: 50px;*/
        background-color: #f2f2f2;
        padding: 20px;
        font-size: 14px;
        color: #999;
    }
.down{
    float: right;
    text-align: center;
    line-height: 30px;
    font-size: 14px;
    color: #fff;
    width: 88px;
    height: 30px;
    background-color: rgb(45, 183, 245);
}
/*  评论  */
.evaluation {
    margin-top: 15px;
}
.comments {
    margin-top: 10px;
    width: 1154px;
    height: 163px;
    border: 1px solid #ddd;
    outline: #00cf8c;
    resize: none;
    font-size: 16px;
}
.comments:hover {
    border: 1px solid #00cf8c;
}
.publish {
    margin-right: 30px;
    float: right;
    margin-top: 6px;
    width: 88px;
    height: 32px;
    line-height: 32px;
    text-align: center;
    color: white;
    background: #00cf8c;
}
.line {
    width: 1150px;
    margin-top: 68px;
    border-bottom: 1px solid #ddd;
}
.head-portrait {
    margin-top: 10px;
}
.circle-img {
    width: 40px;
    height: 40px;
    /*background: black;*/
    border-radius: 50%;
    float: left;
}
.circle-img>img{
    width: 100%;
    height: 100%;
    border-radius: 50%;
}
.head {
    float: left;
    margin-top: 10px;
    margin-left: 13px;
}
.star-1 {
    float: right;
    margin-right: 45px;
    margin-top: 20px;

}
.text-1 {
    margin-left: 50px;
    margin-top: 10px;
}
.paging {
    width: 480px;
    margin: 20px auto;
}
.time{
    float: right;
    margin-left: 10px;
    font-size: 14px;
    color: #777;
}
.reply{
        float: right;
        font-size: 14px;
        color: #777;
}
.reply-box{
      overflow: hidden;
    width: 1177px;
}
/* 二级评论*/
.reply-box-2{
    margin: 10px auto;
    position: relative;
    height: 80px;
    width: 1100px;
    /*background-color: #f2f2f2;*/
    border: 1px solid gainsboro;
}
.replay-box-content{
    margin-top: 10px;
}
.portrait-time{
    position: absolute;
    right: 0;
    bottom: 0;
    font-size: 14px;
    color: #777;
}
.portrait-name{
    margin-left: 10px;
    margin-top: 10px;
    float: left;
    font-width: 500;
    color: rgb(24, 144, 255);
}
.portrait-reply,.portrait-content{
    margin-left: 10px;
    margin-top: 10px;
    float: left;
    font-width: 500;
    color: #777;
}
.head-portrait-2{
    width: 40px;
    height: 40px;
    border-radius: 50%;
}
.portrait{
    float: left;
    vertical-align: middle;

}
</style>